#ifndef __IBT_COMMON_H__
#define __IBT_COMMON_H__

#include <stdbool.h>
#include <stdint.h>
#include <config.h>

#include <sys/prctl.h>

#define ZRT_CAMERA_VERSION "Ver_3_0_20180529_Barracks"

/* Thread name */
#define SET_THREAD_NAME(name) (prctl(PR_SET_NAME, (unsigned long)name))

//#define PROFILES_NAME "/etc/profiles/IBT_Profiles.ini"
#define PROFILES_NAME "/config/bsp_profile.ini"
#define MP4_RECORD_PATH "/tmp/mnt/sdcard"

typedef void				IBT_VOID;
typedef char				IBT_CHAR;
typedef int					IBT_INT;
typedef bool				IBT_BOOL;
typedef unsigned char		IBT_UC;
typedef unsigned int		IBT_UI;
typedef unsigned long		IBT_UL;
typedef unsigned long long	IBT_ULL;
typedef unsigned short		IBT_US;
typedef void				*IBT_PTR;

typedef struct {
	int (*IBT_Event_PowerOff)(int level);
} IBTEventCallback;

typedef struct IBTMsgMgrHandler IBTMsgMgrHandler;
typedef struct IBTSystemHandler IBTSystemHandler;
typedef struct IBTVideoHandler IBTVideoHandler;
typedef struct IBTFilterHandler IBTFilterHandler;
typedef struct IBTAudioHandler IBTAudioHandler;
typedef struct IBTP2PHandler IBTP2PHandler;
typedef struct IBTPushHandler IBTPushHandler;
typedef struct IBTProfilesHandler IBTProfilesHandler;
typedef struct IBTPowerHandler IBTPowerHandler;
typedef struct IBTAlarmHandler IBTAlarmHandler;
typedef struct IBTMp4RecordHandler IBTMp4RecordHandler;
typedef struct IBTFbHandler IBTFbHandler;

typedef struct {
	IBT_INT				gProcessRun;
	IBTMsgMgrHandler	*msgMgr;
	IBTSystemHandler	*system;
	IBTVideoHandler		*video;
	IBTFilterHandler	*filter;
	IBTAudioHandler		*audio;
	IBTP2PHandler		*p2p;
	IBTPushHandler		*push;
	IBTPowerHandler		*power;
	IBTAlarmHandler		*alarm;
	IBTProfilesHandler	*profiles;
	IBTMp4RecordHandler	*mp4;
	IBTFbHandler		*fb;
} IBTHandler;


#if FB_LCD
#define HWINFO_STREAM_CNT	2
#else
#define HWINFO_STREAM_CNT   1
#endif

#define VENC_RC_MODE	ENC_RC_MODE_SMART

#define SENSOR_FRAME_RATE_NUM		SENSOR_FRAME_RATE
#define SENSOR_FRAME_RATE_DEN		1

#define SENSOR_WIDTH_SECOND		640
#define SENSOR_HEIGHT_SECOND		360

//#define FR_OUT_HIGH_WIDTH SENSOR_WIDTH
//#define FR_OUT_HIGH_HEIGHT SENSOR_HEIGHT

#define SENSOR_OV9732_ADDR 0x36
#define SENSOR_PS5250_ADDR 0x48
#define SENSOR_PS5260_ADDR 0x48
#define SENSOR_JXH62_ADDR 0x48
#define SENSOR_SC2235_ADDR 0x30
#define SENSOR_SC2232_ADDR 0x30
#define SENSOR_JXF23_ADDR 0x40
#define SENSOR_PS5250_MIPI_ADDR 0x48
#define SENSOR_GC2053_ADDR 0x37
#define SENSOR_OS05A10_ADDR 0x36

// Common Funciton
int IBT_Product_Is_Single(void);
int cmdline_get_env(char *token, char *param, char *result);
int64_t getTimer();

#endif
